#include "KinectInterface.h"

KinectInterface::KinectInterface(){
    //device = &freenect.createDevice(0);
    running = false;

}


KinectInterface::~KinectInterface(){


}

/** @brief Start retrieval of video and depth data
*   @param
*   @return
*
* Makes a call to the start functions of the device
*
*/
void KinectInterface::run(){
    if(!running){
        //device->startVideo();
        //device->startDepth();
        running = true;
    }
}

/** @brief Get RGB data
*   @param Mat &mat
*   @return
*
* Stores current video frame in refererence variable
*
*/
void KinectInterface::getRgbFrame(Mat &mat){
    //device->getVideo(mat);
    IplImage *image = freenect_sync_get_rgb_cv(0);
    //if(image){
        mat = image;
        cv::cvtColor(mat, mat, CV_RGB2BGR);
    //}
}

/** @brief Get depth data
*   @param Mat &mat
*   @return
*
* Stores current depth frame in refererence variable
*
*/
void KinectInterface::getDepthFrame(Mat &mat){
    //device->getDepth(mat);
    Mat output;
    IplImage *image = freenect_sync_get_depth_cv(0);
    //if(image){
        output = image;
    //}
    mat = output;
    //const float depth = k3 * tanf(i/k2 + k1);
}

/** @brief Stop retrieval of video and depth data
*   @param
*   @return
*
* Makes a call to the stop functions of the device
*/
void KinectInterface::stop(){
    if(running){
        //device->stopVideo();
        //device->stopDepth();
        running = false;
    }
}
